package com.fsc.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fsc.entity.ResultWrapper;
import com.fsc.entity.domain.SchoolInfo;
import com.fsc.entity.domain.SchoolNews;
import com.fsc.entity.domain.SchoolPicture;
import com.fsc.entity.vo.SchoolVO;
import com.fsc.service.SchoolInfoService;
import com.fsc.mapper.SchoolInfoMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.fsc._enum.ReturnEnum.SUCCESS;

/**
* @author 86183
* @description 针对表【school_info(学校信息表)】的数据库操作Service实现
* @createDate 2024-06-02 13:15:22
*/
@Service
public class SchoolInfoServiceImpl extends ServiceImpl<SchoolInfoMapper, SchoolInfo>
    implements SchoolInfoService{
    @Autowired
    private SchoolInfoMapper schoolInfoMapper;
    public ResultWrapper<SchoolVO> selectById(int schoolId){
        SchoolVO schoolVO = new SchoolVO();
        SchoolInfo schoolInfo = schoolInfoMapper.getSchoolById(schoolId);
        List<SchoolNews> news = schoolInfoMapper.getSchoolNews(schoolId);
        List<SchoolPicture> pictures = schoolInfoMapper.getSchoolPicture(schoolId);
        BeanUtils.copyProperties(schoolInfo, schoolVO);
        schoolVO.setNews(news);
        schoolVO.setPicture(pictures);
        return ResultWrapper.success(SUCCESS,schoolVO);
    }

}




